<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: taglisting.php 217 2013-09-22 08:01:08Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 217 $
* 	zuletzt geändert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-22 08:01:08 +0000 (Sun, 22 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

include('includes/application_top.php');

if(!isset($_GET['tag']) || ($_GET['tag'] ==''))
	redirect(href_link(FILENAME_DEFAULT));

$module_smarty = new Smarty();
$module_smarty->assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');

require(DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/source/boxes.php');
require_once(DIR_WS_INCLUDES.'xajax/xajax_core/xajax.inc.php');
include(DIR_WS_INCLUDES.'xajax/xajax.add_cart.php');
include('includes/header.php');

$breadcrumb->add('Tags zu '.$_GET['tag'], href_link('taglisting.php', '', 'SSL'));

$fsk_lock = '';
if($_SESSION['customers_status']['customers_fsk18_display'] == '0')
	$fsk_lock = ' AND p.products_fsk18 != 1';

$group_check = '';
if(GROUP_CHECK == 'true')
	$group_check = " AND p.group_permission_".$_SESSION['customers_status']['customers_status_id']." = 1 ";

$sorting = ' GROUP BY p.products_id ORDER BY pd.products_name ';

$listing_sql = "SELECT
					p.products_fsk18,
					p.products_shippingtime,
					p.products_model,
					p.products_ean,
					pd.products_name,
					m.brand_name,
					p.products_quantity,
					p.products_image,
					p.products_weight,
					pd.products_short_description,
					pd.products_description,
					p.products_id,
					p.products_list_overlay,
					p.brand_id,
					p.products_price,
					p.products_vpe,
					p.products_vpe_status,
					p.products_vpe_value,
					p.products_discount_allowed,
					p.products_tax_class_id,
					t2p.pID,
					t2p.tag
				FROM
					".TABLE_TAG_TO_PRODUCT." t2p
				LEFT JOIN
					".TABLE_PRODUCTS_DESCRIPTION." pd ON pd.products_id = t2p.pID
				LEFT JOIN
					".TABLE_PRODUCTS." p ON p.products_id = t2p.pID
					LEFT JOIN
					".TABLE_BRAND." m ON p.brand_id = m.brand_id
					LEFT JOIN
					".TABLE_SPECIALS." s ON p.products_id = s.products_id
				WHERE
					p.products_status = '1'
				AND
					t2p.tag = ".$db->db_prepare($_GET['tag'])."
				AND
					pd.language_id = '".(int)$_SESSION['languages_id']."'".$filter_products.$group_check.$fsk_lock;

$getCount = $db->db_query("SELECT
								pID
							FROM
								".TABLE_TAG_TO_PRODUCT."
							WHERE
								tag = ".$db->db_prepare($_GET['tag'])."
							GROUP BY
								pID", true);

$listing = new page_break($listing_sql, $_GET['page'], true, 'taglisting.php', 'tagcloud');

if($listing->result) {
	$module_content = array();
	$rows = 0;
	while(!$listing->sql_string->EOF) { $rows++;
		if($listing->listName == 'mosaic' && empty($listing->sql_string->fields['products_image'])) {}
		else $module_content[] = $product->buildDataArray($listing->sql_string->fields, 'thumbnail', $listing->listData, $rows);
		$listing->sql_string->MoveNext();
	}

	$module_smarty->assign('language', $_SESSION['language']);

	$module_smarty->assign('TAG_COUNT', 'dazu gibt es '.$getCount->_numOfRows.' Treffer<br /><br />');
	$module_smarty->assign('TITLE', 'Tag: '.$_GET['tag']);
	$module_smarty->assign('NAVIGATION', $listing->getLinks());
	$module_smarty->assign('LIST_NAME', $listing->page_name);
	$module_smarty->assign('CLASS_NAME', $listing->listName);
	$module_smarty->assign('module_content', $module_content);

	include(DIR_WS_MODULES.'page_per_site.php');
	include(DIR_WS_MODULES.'page_mulit_sort.php');
	include(DIR_WS_MODULES.'page_brand.php');
	include(DIR_WS_MODULES.'page_view_as.php');
	
	if (!CacheCheck()) {
		$module_smarty->caching = false;
		$module = $module_smarty->fetch(CURRENT_TEMPLATE.'/module/'.$listing->listData['list_file'].'.html');
	} else {
		$module_smarty->caching = true;
		$module_smarty->cache_lifetime = CACHE_LIFETIME;
		$module_smarty->cache_modified_check = CACHE_CHECK;
		$cache_id = strtolower($_GET['tag']).'_'.$_SESSION['language'].'_'.$_SESSION['customers_status']['customers_status_name'].'_'.$_SESSION['currency'].'_'.$_GET['brand_id'].'_'.$_GET['filter_id'].'_'.$_GET['page'];
		$module = $module_smarty->fetch(CURRENT_TEMPLATE.'/module/'.$listing->listData['list_file'].'.html', $cache_id);
	}

} else {
	$error = 'Es wurde kein Produkt mit diesem Tag gefunden.';
	include(DIR_WS_MODULES.FILENAME_ERROR_HANDLER);
}
$smarty->loadFilter('output', 'note');
$smarty->loadFilter('output','trimwhitespace');
$smarty->assign('language', $_SESSION['language']);
$smarty->assign('main_content', $module);
$smarty->display(CURRENT_TEMPLATE.'/index.html');
include('includes/application_bottom.php');